package educational.cad.model;

/**
 * This class represents an abstract wire segment (part of wire).
 * 
 * @author Sergey Seroshtan
 * 
 */
public final class WireSegment {

	public WireSegment(Position start, Position end) {
		if (start == null) {
			throw new IllegalArgumentException("Wire segment start is undefined.");
		}
		if (end == null) {
			throw new IllegalArgumentException("Wire segment end is undefined.");
		}

		this.start = start;
		this.end = end;
	}

	public Position startsIn() {
		return start;
	}

	public Position endsIn() {
		return end;
	}

	private final Position start;
	private final Position end;

	@Override
	public boolean equals(Object another) {
		return this.start == ((WireSegment)another).start && this.end == ((WireSegment)another).end; 
	}

	@Override
	public int hashCode() {
		int hash = 17;
		hash = 31 * hash + start.hashCode();
		hash = 31 * hash + end.hashCode();
		return hash;
	}
}
